{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "README.md                    recipeitems-latest (1).json\n",
      "SH_ty1.json                  shanghan.txt\n",
      "Untitled.ipynb               shanghan1.txt\n",
      "Untitled1.ipynb              shanghanfang.json\n",
      "WX_yao.json                  t1.ipynb\n",
      "blog.ipynb                   test1.txt\n",
      "craft1.ipynb                 untitled.dio\n",
      "\u001b[31mhi.csv\u001b[m\u001b[m*                      yuanjue.txt\n",
      "learn_pandas1.ipynb          思路.md\n"
     ]
    }
   ],
   "source": [
    "ls"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = open('recipeitems-latest (1).json').readlines()[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'_id': {'$oid': '5160756b96cc62079cc2db15'},\n",
       " 'name': 'Drop Biscuits and Sausage Gravy',\n",
       " 'ingredients': 'Biscuits\\n3 cups All-purpose Flour\\n2 Tablespoons Baking Powder\\n1/2 teaspoon Salt\\n1-1/2 stick (3/4 Cup) Cold Butter, Cut Into Pieces\\n1-1/4 cup Butermilk\\n SAUSAGE GRAVY\\n1 pound Breakfast Sausage, Hot Or Mild\\n1/3 cup All-purpose Flour\\n4 cups Whole Milk\\n1/2 teaspoon Seasoned Salt\\n2 teaspoons Black Pepper, More To Taste',\n",
       " 'url': 'http://thepioneerwoman.com/cooking/2013/03/drop-biscuits-and-sausage-gravy/',\n",
       " 'image': 'http://static.thepioneerwoman.com/cooking/files/2013/03/bisgrav.jpg',\n",
       " 'ts': {'$date': 1365276011104},\n",
       " 'cookTime': 'PT30M',\n",
       " 'source': 'thepioneerwoman',\n",
       " 'recipeYield': '12',\n",
       " 'datePublished': '2013-03-11',\n",
       " 'prepTime': 'PT10M',\n",
       " 'description': 'Late Saturday afternoon, after Marlboro Man had returned home with the soccer-playing girls, and I had returned home with the...'}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "json.loads(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[ i ** i for i in range(10)]  # 列表生成shi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = open(\"SH_ty1.json\").read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = pd.read_json(\"SH_ty1.json\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "六经                              {'阴阳': '阳', '三经': '太阳'}\n",
       "原文    {'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...\n",
       "方       {'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}\n",
       "证     {'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...\n",
       "Name: 桂枝汤, dtype: object"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.loc[\"桂枝汤\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>桂枝汤</th>\n",
       "      <th>桂枝加葛根汤</th>\n",
       "      <th>桂枝加附子汤</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>六经</th>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>原文</th>\n",
       "      <td>{'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...</td>\n",
       "      <td>{'对应证原文': ['太阳病，项背强几几，反汗出恶风者，桂枝加葛根汤主之。', '太阳与阳...</td>\n",
       "      <td>{'对应证原文': ['太阳病，发汗，遂漏不止，其人恶风，小便难，四支微急，难以屈伸者，桂枝...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>方</th>\n",
       "      <td>{'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}</td>\n",
       "      <td>{'葛根': 4, '桂枝': 3, '芍药': 2, '炙甘草': 2, '生姜': 3,...</td>\n",
       "      <td>{'附子': 1, '桂枝': 3, '芍药': 3, '炙甘草': 3, '生姜': 3,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>证</th>\n",
       "      <td>{'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...</td>\n",
       "      <td>{'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}</td>\n",
       "      <td>{'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  桂枝汤  \\\n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}   \n",
       "原文  {'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...   \n",
       "方     {'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}   \n",
       "证   {'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...   \n",
       "\n",
       "                                               桂枝加葛根汤  \\\n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}   \n",
       "原文  {'对应证原文': ['太阳病，项背强几几，反汗出恶风者，桂枝加葛根汤主之。', '太阳与阳...   \n",
       "方   {'葛根': 4, '桂枝': 3, '芍药': 2, '炙甘草': 2, '生姜': 3,...   \n",
       "证                 {'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}   \n",
       "\n",
       "                                               桂枝加附子汤  \n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}  \n",
       "原文  {'对应证原文': ['太阳病，发汗，遂漏不止，其人恶风，小便难，四支微急，难以屈伸者，桂枝...  \n",
       "方   {'附子': 1, '桂枝': 3, '芍药': 3, '炙甘草': 3, '生姜': 3,...  \n",
       "证   {'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "a.loc[\"体证\"] = a.loc['证'].apply(lambda x: x[\"体证\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>桂枝汤</th>\n",
       "      <th>桂枝加葛根汤</th>\n",
       "      <th>桂枝加附子汤</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>六经</th>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>原文</th>\n",
       "      <td>{'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...</td>\n",
       "      <td>{'对应证原文': ['太阳病，项背强几几，反汗出恶风者，桂枝加葛根汤主之。', '太阳与阳...</td>\n",
       "      <td>{'对应证原文': ['太阳病，发汗，遂漏不止，其人恶风，小便难，四支微急，难以屈伸者，桂枝...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>方</th>\n",
       "      <td>{'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}</td>\n",
       "      <td>{'葛根': 4, '桂枝': 3, '芍药': 2, '炙甘草': 2, '生姜': 3,...</td>\n",
       "      <td>{'附子': 1, '桂枝': 3, '芍药': 3, '炙甘草': 3, '生姜': 3,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>证</th>\n",
       "      <td>{'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...</td>\n",
       "      <td>{'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}</td>\n",
       "      <td>{'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>体证</th>\n",
       "      <td>[发热, 鼻涕, 怕冷, 怕风, 干呕, 头痛, 出汗]</td>\n",
       "      <td>[肌肉酸痛, 怕风]</td>\n",
       "      <td>[大量出汗不止, 怕风, 小便难, 四肢难以屈伸]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  桂枝汤  \\\n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}   \n",
       "原文  {'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...   \n",
       "方     {'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}   \n",
       "证   {'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...   \n",
       "体证                       [发热, 鼻涕, 怕冷, 怕风, 干呕, 头痛, 出汗]   \n",
       "\n",
       "                                               桂枝加葛根汤  \\\n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}   \n",
       "原文  {'对应证原文': ['太阳病，项背强几几，反汗出恶风者，桂枝加葛根汤主之。', '太阳与阳...   \n",
       "方   {'葛根': 4, '桂枝': 3, '芍药': 2, '炙甘草': 2, '生姜': 3,...   \n",
       "证                 {'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}   \n",
       "体证                                         [肌肉酸痛, 怕风]   \n",
       "\n",
       "                                               桂枝加附子汤  \n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}  \n",
       "原文  {'对应证原文': ['太阳病，发汗，遂漏不止，其人恶风，小便难，四支微急，难以屈伸者，桂枝...  \n",
       "方   {'附子': 1, '桂枝': 3, '芍药': 3, '炙甘草': 3, '生姜': 3,...  \n",
       "证   {'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...  \n",
       "体证                          [大量出汗不止, 怕风, 小便难, 四肢难以屈伸]  "
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "桂枝汤       {'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...\n",
       "桂枝加葛根汤                  {'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}\n",
       "桂枝加附子汤    {'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...\n",
       "Name: 证, dtype: object"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z = a.loc['证']\n",
    "z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "桂枝汤       {'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...\n",
       "桂枝加葛根汤                  {'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}\n",
       "桂枝加附子汤    {'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...\n",
       "Name: 证, dtype: object"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.loc['证']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = pd.Series()\n",
    "for idx, d in a.iteritems():\n",
    "    s[dix] = d['体证']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>桂枝汤</th>\n",
       "      <th>桂枝加葛根汤</th>\n",
       "      <th>桂枝加附子汤</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>六经</th>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "      <td>{'阴阳': '阳', '三经': '太阳'}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>原文</th>\n",
       "      <td>{'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...</td>\n",
       "      <td>{'对应证原文': ['太阳病，项背强几几，反汗出恶风者，桂枝加葛根汤主之。', '太阳与阳...</td>\n",
       "      <td>{'对应证原文': ['太阳病，发汗，遂漏不止，其人恶风，小便难，四支微急，难以屈伸者，桂枝...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>方</th>\n",
       "      <td>{'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}</td>\n",
       "      <td>{'葛根': 4, '桂枝': 3, '芍药': 2, '炙甘草': 2, '生姜': 3,...</td>\n",
       "      <td>{'附子': 1, '桂枝': 3, '芍药': 3, '炙甘草': 3, '生姜': 3,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>证</th>\n",
       "      <td>{'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...</td>\n",
       "      <td>{'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}</td>\n",
       "      <td>{'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>体证</th>\n",
       "      <td>[发热, 鼻涕, 怕冷, 怕风, 干呕, 头痛, 出汗]</td>\n",
       "      <td>[肌肉酸痛, 怕风]</td>\n",
       "      <td>[大量出汗不止, 怕风, 小便难, 四肢难以屈伸]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  桂枝汤  \\\n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}   \n",
       "原文  {'对应证原文': ['太阳中风，阳浮而阴弱，阳浮者热自发，阴弱者汗自出，啬啬恶寒，淅淅恶风...   \n",
       "方     {'桂枝': 3, '芍药': 3, '炙甘草': 2, '生姜': 3, '大枣': 12}   \n",
       "证   {'体证': ['发热', '鼻涕', '怕冷', '怕风', '干呕', '头痛', '出...   \n",
       "体证                       [发热, 鼻涕, 怕冷, 怕风, 干呕, 头痛, 出汗]   \n",
       "\n",
       "                                               桂枝加葛根汤  \\\n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}   \n",
       "原文  {'对应证原文': ['太阳病，项背强几几，反汗出恶风者，桂枝加葛根汤主之。', '太阳与阳...   \n",
       "方   {'葛根': 4, '桂枝': 3, '芍药': 2, '炙甘草': 2, '生姜': 3,...   \n",
       "证                 {'体证': ['肌肉酸痛', '怕风'], '脉证': ['无']}   \n",
       "体证                                         [肌肉酸痛, 怕风]   \n",
       "\n",
       "                                               桂枝加附子汤  \n",
       "六经                            {'阴阳': '阳', '三经': '太阳'}  \n",
       "原文  {'对应证原文': ['太阳病，发汗，遂漏不止，其人恶风，小便难，四支微急，难以屈伸者，桂枝...  \n",
       "方   {'附子': 1, '桂枝': 3, '芍药': 3, '炙甘草': 3, '生姜': 3,...  \n",
       "证   {'体证': ['大量出汗不止', '怕风', '小便难', '四肢难以屈伸'], '脉证'...  \n",
       "体证                          [大量出汗不止, 怕风, 小便难, 四肢难以屈伸]  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "ser = a.loc['证'].apply(lambda x: set(x[\"体证\"]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "桂枝汤       {发热, 鼻涕, 干呕, 头痛, 出汗, 怕风, 怕冷}\n",
       "桂枝加葛根汤                      {怕风, 肌肉酸痛}\n",
       "桂枝加附子汤       {怕风, 大量出汗不止, 四肢难以屈伸, 小便难}\n",
       "Name: 证, dtype: object"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "bz = {\"怕风\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "桂枝汤       {发热, 鼻涕, 干呕, 头痛, 出汗, 怕风, 怕冷}\n",
       "桂枝加葛根汤                      {怕风, 肌肉酸痛}\n",
       "桂枝加附子汤       {怕风, 大量出汗不止, 四肢难以屈伸, 小便难}\n",
       "Name: 证, dtype: object"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser[ser.apply(lambda x: bz < x)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "{1, 2} < set([1,2,3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "桂枝汤       {发热, 鼻涕, 干呕, 头痛, 出汗, 怕风, 怕冷}\n",
       "桂枝加葛根汤                      {怕风, 肌肉酸痛}\n",
       "桂枝加附子汤       {怕风, 大量出汗不止, 四肢难以屈伸, 小便难}\n",
       "Name: 证, dtype: object"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ser[[]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'发热', '鼻涕', '干呕', '头痛', '出汗', '怕风', '怕冷'}\n",
      "{'怕风', '肌肉酸痛'}\n",
      "{'怕风', '大量出汗不止', '四肢难以屈伸', '小便难'}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "桂枝汤       None\n",
       "桂枝加葛根汤    None\n",
       "桂枝加附子汤    None\n",
       "Name: 证, dtype: object"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser.apply(lambda x: print(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['桂枝汤', '桂枝加葛根汤', '桂枝加附子汤']"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = pd.read_json(\"SH_ty1.json\")\n",
    "tz = a.loc['证'].apply(lambda x: set(x[\"体证\"]))\n",
    "bz = {\"怕风\"}\n",
    "list(tz[tz.apply(lambda x: bz < x)].index)  # 布尔选取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
